package com.mrd.gtimp.business.service;

import com.mrd.base.BaseBiz;
import com.mrd.constant.BaseTypeConstant;
import com.mrd.gtimp.business.entity.TaxInform;
import com.mrd.spring.repository.BaseRepository;
import com.mrd.util.CollectionUtil;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

/**
 * <p> application name: gtimp <p> copyright: Copyright@2012 明睿达科技有限公司
 */

/**
 * @author luob
 */
@Service
public class TaxInformBiz extends BaseBiz<TaxInform> {


    @Resource
    // 该处指定注入BaseRepository的dao对象
    @Qualifier("taxInformDao")
    public void setBaseRepository(BaseRepository<TaxInform, String> baseRepository) {
        super.baseRepository = baseRepository;
    }


    public void updateReturnTax(String taxId) throws Exception {
    }


    public void updateReturnTax(String taxId, String validator) throws Exception {
        TaxInform entity = new TaxInform();
        entity.setId(taxId);
        entity.setState(BaseTypeConstant.TAX_STATE_3);
        entity.setReturnDate(new Date());
        entity.setValidatorExt(validator);
        entity.setAlertState("2");
        String[] pStrings = {"state", "returnDate", "validatorExt", "alertState"};
        List<String> properties = CollectionUtil.arrToList(pStrings);
        updateEntity(entity, properties);
    }


    public void updateBackTax(String taxId, String validator) throws Exception {
        TaxInform entity = new TaxInform();
        entity.setId(taxId);
        entity.setState(BaseTypeConstant.TAX_STATE_1);
        entity.setValidatorExt(validator);
        String[] pStrings = {"state", "validatorExt"};
        List<String> properties = CollectionUtil.arrToList(pStrings);
        updateEntity(entity, properties);
    }


    public void updateAlertTax(String taxId) throws Exception {
        TaxInform entity = new TaxInform();
        entity.setId(taxId);
        entity.setAlertState("1");
        String[] pStrings = {"alertState"};
        List<String> properties = CollectionUtil.arrToList(pStrings);
        updateEntity(entity, properties);
    }

}
